package epin.fujiajun.data.array;

import epin.fujiajun.data.Array;

import java.util.Random;

/**
 * Created by DELL on 2017/8/28.
 */
public class Letter extends Array<Letter> {

    private final char letter;

    public Letter(char letter) {
        this.letter = letter;
    }

    public char getLetter() {
        return letter;
    }

    @Override
    public String toString() {
        return String.valueOf(letter).toString();
    }

    @Override
    public int compareTo(Letter o) {
        if (this.letter > o.letter) return +1;
        if (this.letter < o.letter) return -1;
        return 0;
    }


    public static Letter[] createArray(int size){
        Letter[] a = new Letter[size];
        Random random = new Random();

        for (int i = 0;i < size;i++){
            int num = random.nextInt(1000) + 1;
            Letter letter = new Letter((char) (num % 26 + 65));
            a[i] = letter;
        }

        return a;
    }


    public static Letter[] createArray(char[] letters){
        Letter[] a = new Letter[letters.length];

        for (int i = 0; i < letters.length; i++){
            a[i] = new Letter(letters[i]);
        }

        return a;
    }

}
